import { CylinderGeometry, Mesh, MeshBasicMaterial } from "three";
import { Point } from "../../Engine";
/**
 * 圆柱体
 */
export default class Cylinder extends Mesh {
    /**
     * 圆柱体
     * @param cylinderData 构建圆柱体需要的参数
     * @param cylinderData.radius 圆柱体的半径
     * @param cylinderData.height 圆柱体的长度
     * @param cylinderData.color 圆柱体的颜色
     * @param cylinderData.alpha 圆柱体的透明度
     * @param cylinderData.position 圆柱体的位置
     * @example let cylinderPosition = new GE.Point(13377184.375437068, 3540339.2581293588, 0, '3857');
        let cylinderData = {
            radius: 100, //圆柱体的半径
            height: 100,  //圆柱体的高度
            color: '#DC143C',  //圆柱体的颜色
            alpha: 0.5,  //圆柱体的透明度
            position: cylinderPosition //圆柱体的位置
        };
        let cylinder = new GE.Cylinder(cylinderData); 
        app.add(cylinder);
     */
    public constructor(cylinderData: {radius: number, height: number, color: string, alpha: number, position: Point}){
        super();

        let radius = cylinderData.radius;
        let height = cylinderData.height;
        this.geometry = new CylinderGeometry(radius, radius, height, 32 ); 
        this.material = new MeshBasicMaterial( {color: cylinderData.color, opacity: cylinderData.alpha, transparent: true} ); 

        cylinderData.position.toEPSGWeb();
        this.position.copy(cylinderData.position);
        this.position.z += height / 2;

        this.rotateX(Math.PI/2);
    }
}